home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 April: Mac OS SDK / Dev.CD Apr 00 SDK1.toast / Development Kits / Mac OS / AppleShare IP 6.3 SDK / ASIP User Authentication Module / Client UAM SDK / Headers / ClientUAM.h < prev   
Encoding:
C/C++ Source or Header  |  1999-11-01  |  13.1 KB  |  430 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        ClientUAM.h
  3.  
  4.      Contains:    Public Header file for the AppleShare Client UAM API 
  5.  
  6.      Version:    3.8
  7.   
  8.      Copyright:    © 1999 by Apple Computer, Inc., all rights reserved.
  9.  
  10.  
  11. */
  12. #ifndef __CLIENTUAM__
  13. #define __CLIENTUAM__
  14.  
  15. #ifndef __CONDITIONALMACROS__
  16. #include <ConditionalMacros.h>
  17. #endif
  18. #ifndef __MIXEDMODE__
  19. #include <MixedMode.h>
  20. #endif
  21. #ifndef __DEVICES__
  22. #include <Devices.h>
  23. #endif
  24. #ifndef __APPLETALK__
  25. #include <AppleTalk.h>
  26. #endif
  27. #ifndef __OPENTRANSPORT__
  28. #include <OpenTransport.h>
  29. #endif
  30. #ifndef __OPENTPTINTERNET__
  31. #include <OpenTptInternet.h>
  32. #endif
  33. #ifndef __OPENTPTAPPLETALK__
  34. #include <OpenTptAppleTalk.h>
  35. #endif
  36. #ifndef __ERRORS__
  37. #include <errors.h>
  38. #endif
  39. #ifndef __EVENTS__
  40. #include <Events.h>
  41. #endif
  42. #ifndef __AFPDATASTREAM__
  43. #include <afpDatastream.h>
  44. #endif
  45.  
  46.  
  47.  
  48. #if PRAGMA_ONCE
  49. #pragma once
  50. #endif
  51.  
  52. #ifdef __cplusplus
  53. extern "C" {
  54. #endif
  55.  
  56. #if PRAGMA_IMPORT
  57. #pragma import on
  58. #endif
  59.  
  60. #if PRAGMA_STRUCT_ALIGN
  61.     #pragma options align=mac68k
  62. #elif PRAGMA_STRUCT_PACKPUSH
  63.     #pragma pack(push, 2)
  64. #elif PRAGMA_STRUCT_PACK
  65.     #pragma pack(2)
  66. #endif
  67.  
  68.  
  69. /* Error values*/
  70.  
  71. enum {
  72.     kUAMError                    = -5002,                        /* afpBadUAM*/
  73.     kNotForUs                    = -50                            /* paramErr*/
  74. };
  75.  
  76. /* UAM Class & Type values*/
  77.  
  78. enum {
  79.     kUAMStdClass                = 0,                            /* Standard UAM (8 byte password)*/
  80.     kUAMVarClearClass            = 1,                            /* variable length cleartext password*/
  81.     kUAMVarCryptClass            = 2,                            /* variable length encrypted password*/
  82.     kUAMUserDefClass            = 3                                /* Custom UAM*/
  83. };
  84.  
  85.  
  86. enum {
  87.     kNoPasswd                    = 1,                            /* Class 0, No User Authentication (Guest)*/
  88.     kCleartextPasswd            = 2,                            /* Class 0, Cleartext password (8 byte password)*/
  89.     kEncryptPasswd                = 3,                            /* Class 0, RandnumExchange (8 byte password)*/
  90.     kVarPasswd                    = 4,                            /* Class 1, variable length cleartext password*/
  91.     kVarEncryptPasswd            = 5,                            /* Class 2, variable length encrypted password*/
  92.     kTwoWayEncryptPasswd        = 6                                /* Class 0, two way randnum exchange (8 byte password)*/
  93. };
  94.  
  95. /* general constants*/
  96.  
  97. enum {
  98.     kMaxAFPCommand                = 576,
  99.     kStdPWdLength                = 8,
  100.     kMaxPwdLength                = 64
  101. };
  102.  
  103.  
  104. /* UAM Commands    */
  105.  
  106. enum {
  107.     kUAMOpen                    = 0,
  108.     kUAMPWDlog                    = 1,
  109.     kUAMLogin                    = 2,
  110.     kUAMVSDlog                    = 3,
  111.     kUAMChgPassDlg                = 4,
  112.     kUAMChgPass                    = 5,
  113.     kUAMGetInfoSize                = 6,
  114.     kUAMGetInfo                    = 7,
  115.     kUAMClose                    = 8,
  116.     kUAMPrOpen                    = 9,
  117.     kUAMPrAuthDlog                = 10,
  118.     kUAMPrAuth                    = 11
  119. };
  120.  
  121.  
  122.  
  123. /* config bits*/
  124.  
  125. enum {
  126.     kUsePWDlog                    = 0,                            /* The UAM wants to put up its own Password/PRAuth Dialog*/
  127.     kUseVolDlog                    = 1,                            /* The UAM wants to put up its own Volume Selection DIalog*/
  128.     kSupportsCP                    = 2,                            /* The UAM supports Changing the password*/
  129.     kUseCPDlog                    = 3,                            /* The UAM wants to put up its own Change Password Dialog*/
  130.     kUseUAMInfo                    = 4                                /* The UAM supports storing authentication info in UAMInfo*/
  131. };
  132.  
  133. /* All other bits are reserved and must be set to 0*/
  134.  
  135.  
  136. /* structs*/
  137.  
  138.  
  139.  
  140. struct ClientInfo {
  141.     short                             fInfoType;                    /* the type of ClientInfo*/
  142.     Str255                             fDefaultUserName;            /* a pointer to the Default User name*/
  143. };
  144. typedef struct ClientInfo ClientInfo;
  145.  
  146.  
  147. enum {
  148.     kAFPClientInfo                = 0,
  149.     kPrClientInfo                = 1
  150. };
  151.  
  152. struct AFPClientInfo {
  153.     short                             fInfoType;                    /* the type of ClientInfo (kAFPClientInfo)*/
  154.     Str255                             fDefaultUserName;            /* a pointer to the Default User name*/
  155.     short                             fConfigFlags;                /* the hi  short of the gestalt('afpt') response*/
  156.     short                             fVersion;                    /* the low short of the gestalt('afpt') response*/
  157.     short                             fNumAFPVersions;            /* the number of afp versions supported by this client*/
  158.     StringPtr *                        fAFPVersionStrs;            /* an array of afp version strings supported by this client*/
  159. };
  160. typedef struct AFPClientInfo AFPClientInfo;
  161.  
  162. struct PRClientInfo {
  163.     short                             fInfoType;                    /* the type of ClientInfo (kPrClientInfo)*/
  164.     Str255                             fDefaultUserName;            /* a pointer to the Default User name*/
  165.     FSSpec                             fPPDFile;                    /* the fsspec of the ppd file for the currently selected printer*/
  166. };
  167. typedef struct PRClientInfo PRClientInfo;
  168.  
  169. /* Callbacks:*/
  170.  
  171. /*
  172.    this Completion routine is called with the contextPtr passed in to
  173.    the OpenAFPSession() and SendRequest() calls, when one of these calls
  174.    completes. The result parameter contains the AFP result.
  175.    You cannot call any of the callback routines from this Completion
  176.    routine, so you can't do chained completion routines. This routine
  177.    will be called just like any other completion routine or notifier
  178.    so the usual rules apply.
  179. */
  180.  
  181. typedef CALLBACK_API( void , CompletionPtr )(void *message, OSStatus result);
  182.  
  183. /*    GetClientInfo()
  184.     Returns information about the Client, such as which versions of AFP are
  185.     supported and the various gestalt values. This call also returns the
  186.     default user name. If the infoType is not avaliable it will return nil.
  187.  
  188.     pascal    OSStatus    GetClientInfo(short infoType,ClientInfo    **infoPtr);        
  189. */
  190. struct UAMMessage {
  191.     long                             commandCode;
  192.     short                             sessionRefNum;
  193.     OSStatus                         result;
  194.     unsigned char *                    cmdBuffer;
  195.     unsigned long                     cmdBufferSize;
  196.     unsigned char *                    replyBuffer;
  197.     unsigned long                     replyBufferSize;
  198.     CompletionPtr                     completion;
  199.     void *                            contextPtr;
  200.     UInt8                             scratch[80];                /* scratch space for the client*/
  201. };
  202. typedef struct UAMMessage UAMMessage;
  203.  
  204. typedef UAMMessage *                    UAMMessagePtr;
  205.  
  206. enum {
  207.                                                                 /* commandCodes (for future expansion)*/
  208.     kOpenSession                = FOUR_CHAR_CODE('UAOS'),
  209.     kSendRequest                = FOUR_CHAR_CODE('UASR')
  210. };
  211.  
  212. /*    OpenSession()
  213.     Opens a session to the specified address. If you are using AFP, cmdBuffer MUST 
  214.     contain an AFP Login command. If you are using AFP the command buffer size is limited
  215.     to kMaxAFPCommand (576 bytes). Set endpointString to nil if default is desired 
  216.     (TCP only, it is ignored for AppleTalk connections (and may also be ignored on
  217.     rhapsody)). Leave completion & contextPtr nil for sync. Session reference number 
  218.     is returned in the sessionRefNum field.
  219.  
  220.  
  221.     pascal    OSStatus    OpenSession(OTAddress *, const char* endpointString, UAMMessagePtr);
  222. */
  223. /*     SendRequest()
  224.     Sends a command to the server. If the session is an AFP session, cmdBuffer
  225.     MUST contain an AFP command. If you are using AFP the command buffer size is limited
  226.     to kMaxAFPCommand (576 bytes). Leave completion & contextPtr nil for sync.
  227.     the Session reference number for this connection must be in the sessionRefNum field.
  228.                 
  229.     pascal    OSStatus    SendRequest(UAMMessagePtr);
  230. */
  231.  
  232. /*    CloseSession()
  233.     Closes the session denoted by the sessRefNum;
  234.  
  235.     pascal    OSStatus    CloseSession(short sessRefNum);
  236. */
  237.  
  238. /*    SetMic()
  239.     Sets the message integrity code key. If the connection supports using 
  240.     keyed HMAC-SHA1 for message integrity, the UAM may pass a key down
  241.     to the network layer using this call. 
  242.  
  243.     pascal    OSStatus    SetMic(short sizeInBytes, Ptr micValue);
  244. */
  245. #if GENERATING68K
  246. typedef CALLBACK_API( OSStatus , OpenSessionPtr )(OTAddress *addr, const char *endpointString, UAMMessagePtr message);
  247. typedef CALLBACK_API( OSStatus , SendRequestPtr )(UAMMessagePtr message);
  248. typedef CALLBACK_API( OSStatus , CloseSessionPtr )(short sessRefNum);
  249. typedef CALLBACK_API( OSStatus , GetClientInfoPtr )(short infoType, ClientInfo **info);
  250. typedef CALLBACK_API( OSStatus , SetMicPtr )(short sizeInBytes, Ptr micValue);
  251. typedef CALLBACK_API( void , EventCallbackPtr )(EventRecord *theEvent);
  252. #else
  253. typedef UniversalProcPtr                 OpenSessionPtr;
  254. typedef UniversalProcPtr                 SendRequestPtr;
  255. typedef UniversalProcPtr                 CloseSessionPtr;
  256. typedef UniversalProcPtr                 GetClientInfoPtr;
  257. typedef UniversalProcPtr                 SetMicPtr;
  258. typedef UniversalProcPtr                 EventCallbackPtr;
  259. #endif  /* GENERATING68K */
  260.  
  261. struct ClientUAMCallbackRec {
  262.     OpenSessionPtr                     OpenSessionUPP;
  263.     SendRequestPtr                     SendRequestUPP;
  264.     CloseSessionPtr                 CloseSessionUPP;
  265.     GetClientInfoPtr                 GetClientInfoUPP;
  266.     SetMicPtr                         SetMicUPP;
  267.     EventCallbackPtr                 EventCallbackUPP;
  268. };
  269. typedef struct ClientUAMCallbackRec ClientUAMCallbackRec;
  270.  
  271. struct VolListElem {
  272.     UInt8                             volFlags;                    /* volume flags*/
  273.     Str32                             volName;
  274. };
  275. typedef struct VolListElem VolListElem;
  276.  
  277. /* definitions for the volume flags*/
  278.  
  279. enum {
  280.     kMountFlag                    = 0,                            /* bit indicating this volume is to be mounted (set by the UAM)*/
  281.     kAlreadyMounted                = 1,                            /* bit indicating that the volume is currently mounted*/
  282.     kNoRights                    = 2,                            /* bit indicating that this user has no permission to use the volume*/
  283.     kHasVolPw                    = 7                                /* bit indicating that the volume has a volume password*/
  284. };
  285.  
  286. struct UAMOpenBlk {                                                /* called for UAMOpen & UAMPrOpen*/
  287.     StringPtr                         objectName;                    /* <-    server or printer name*/
  288.     StringPtr                         zoneName;                    /* <-    zone name or nil if no zone is present*/
  289.     OTAddress *                        srvrAddress;                /* <-    OT Address of the "server"    */
  290.     AFPSrvrInfo *                    srvrInfo;                    /* <-    for UAMOpen this is the GetStatus reply, for Printers ???*/
  291. };
  292. typedef struct UAMOpenBlk UAMOpenBlk;
  293.  
  294. struct UAMPWDlogBlk {                                            /* for the password dialog and prAuthDlog*/
  295.     StringPtr                         userName;                    /* <-    pointer to a Str64 containing the user name*/
  296.     unsigned char *                    password;                    /* <-    pointer to a Str64 containing the password*/
  297. };
  298. typedef struct UAMPWDlogBlk UAMPWDlogBlk;
  299.  
  300. struct UAMAuthBlk {                                                /* called for login and prAuthenticate*/
  301.     StringPtr                         userName;                    /* <-    pointer to a Str64 containing the user name*/
  302.     unsigned char *                    password;                    /* <-    pointer to a 64 byte buffer containing the password*/
  303.     OTAddress *                        srvrAddress;                /* <-    OT Address of the "server"    */
  304. };
  305. typedef struct UAMAuthBlk UAMAuthBlk;
  306.  
  307. struct UAMVSDlogBlk {                                            /* for the volume select dialog*/
  308.     short                             numVolumes;                    /* <-    number of volumes in the volume list*/
  309.     VolListElem *                    volumes;                    /* <-    the volume list*/
  310. };
  311. typedef struct UAMVSDlogBlk UAMVSDlogBlk;
  312.  
  313. struct UAMChgPassBlk {                                            /* for both the change password dialog and the change password call*/
  314.     StringPtr                         userName;                    /* <-    pointer to a Str64 containing the user name*/
  315.     unsigned char *                    oldPass;                    /* <-    pointer to a 64 byte buffer containing the old password*/
  316.     unsigned char *                    newPass;                    /* <-    pointer to a 64 byte buffer containing the new password*/
  317. };
  318. typedef struct UAMChgPassBlk UAMChgPassBlk;
  319.  
  320. struct UAMArgs {
  321.     short                             command;                    /* <-    UAM command selector*/
  322.     short                             sessionRefNum;                /* <->    session reference number*/
  323.     long                             result;                        /*  ->    command result*/
  324.     void *                            uamInfo;                    /* <-    pointer to a block of Auth Data*/
  325.     long                             uamInfoSize;                /* <->    size of the Auth Data*/
  326.     ClientUAMCallbackRec *            callbacks;                    /* <-    Callback record */
  327.     union {
  328.         UAMChgPassBlk                     chgPass;
  329.         UAMVSDlogBlk                     vsDlog;
  330.         UAMAuthBlk                         auth;
  331.         UAMPWDlogBlk                     pwDlg;
  332.         UAMOpenBlk                         open;
  333.     }                                 Opt;
  334. };
  335. typedef struct UAMArgs UAMArgs;
  336.  
  337. EXTERN_API( OSStatus )
  338. UAMCall                            (UAMArgs *                theArgs);
  339.  
  340.  
  341.  
  342. /* procinfos*/
  343.  
  344. enum {
  345.     kOpenSessionProcInfo = kPascalStackBased    
  346.             | RESULT_SIZE(SIZE_CODE(sizeof(OSStatus)))    
  347.             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(OTAddress *)))        
  348.             | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(const char*)))        
  349.             | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(UAMMessagePtr))),        
  350.     
  351.     kSendRequestProcInfo =  kPascalStackBased    
  352.             | RESULT_SIZE(SIZE_CODE(sizeof(OSStatus)))    
  353.             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(UAMMessagePtr))),        
  354.     
  355.     kCloseSessionProcInfo =  kPascalStackBased    
  356.             | RESULT_SIZE(SIZE_CODE(sizeof(OSStatus)))    
  357.             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short))),                
  358.     
  359.     kGetClientInfoProcInfo =  kPascalStackBased    
  360.             | RESULT_SIZE(SIZE_CODE(sizeof(OSStatus)))    
  361.             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))    
  362.             | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(ClientInfo **))),        
  363.     
  364.     kSetMicProcInfo =  kPascalStackBased    
  365.             | RESULT_SIZE(SIZE_CODE(sizeof(OSStatus)))    
  366.             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))                
  367.             | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr))),                
  368.     
  369.     kEventCallbackProcInfo =  kPascalStackBased    
  370.             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(EventRecord *))),        
  371.     
  372.     kUAMCallProcInfo =  kPascalStackBased
  373.             | RESULT_SIZE(SIZE_CODE(sizeof(OSStatus)))    
  374.             | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(UAMArgs *)))            
  375. };
  376.  
  377. /* Resouce definitions
  378. */
  379.  
  380. enum {
  381.     kUAMName                    = 0,                            /* user visible name of the UAM*/
  382.     kUAMProtoName                = 1,                            /* protocol name of the UAM (sent to the server in the login cmd)*/
  383.     kUAMDescription                = 2,                            /* short description of the UAM (displayed in the dialog)*/
  384.     kUAMHelpBalloon                = 3                                /* Str255 for the Balloon Help item*/
  385. };
  386.  
  387.  
  388. enum {
  389.     kUAMFileType                = FOUR_CHAR_CODE('uams')        /* Type of the UAM file*/
  390. };
  391.  
  392. /* resource types*/
  393.  
  394. enum {
  395.     kUAMStr                        = FOUR_CHAR_CODE('uamn'),
  396.     kUAMCode                    = FOUR_CHAR_CODE('uamc'),
  397.     kUAMConfig                    = FOUR_CHAR_CODE('uamg')
  398. };
  399.  
  400. /* 'uams' resource IDs    */
  401.  
  402. enum {
  403.     kUAMTitle                    = 0,                            /* UAM Title string (shown in the UAM list)*/
  404.     kUAMProtocol                = 1,                            /* UAM protocol name*/
  405.     kUAMPWStr                    = 2,                            /* UAM description string (shown in the Password dialog)*/
  406.     kUAMBallHelp                = 3                                /* Balloon Help string for the Password dialog.*/
  407. };
  408.  
  409.  
  410. #if PRAGMA_STRUCT_ALIGN
  411.     #pragma options align=reset
  412. #elif PRAGMA_STRUCT_PACKPUSH
  413.     #pragma pack(pop)
  414. #elif PRAGMA_STRUCT_PACK
  415.     #pragma pack()
  416. #endif
  417.  
  418. #ifdef PRAGMA_IMPORT_OFF
  419. #pragma import off
  420. #elif PRAGMA_IMPORT
  421. #pragma import reset
  422. #endif
  423.  
  424. #ifdef __cplusplus
  425. }
  426. #endif
  427.  
  428. #endif /* __CLIENTUAM__ */
  429.  
  430.